﻿@{
    ViewBag.Title = "日志管理_用户（账户）访问情况";
}
@using KingRoad.EPM.Common.Helper
<script type="text/javascript">

    var LastSelectID = 0; //最后一次选中的行ID    
    var List_Permission_Log_Index_Height = 0;
    $(document).ready(function () {
        List_Permission_Log_Index_Height = $("#tabContent").innerHeight() - $(".panelBar",navTab.getCurrentPanel()).outerHeight();

        $("#mainContent_Permission_Log_Index").height(List_Permission_Log_Index_Height);
        GridGet_Permission_Log_Index();
    });

    function GridGet_Permission_Log_Index() {
        $("#List_Permission_Log_Index").jqGrid({
            url: "/Permission/Log/GetLogList",
            datatype: "json",
            mtype: "post",
            colModel: [
                        { label: 'Id', name: 'Id', index: 'Id', width: 1, align: "center", sortable: false, hidden: true },
                        { label: '用户名', name: 'UserName', index: 'UserName', width: 120, align: "center", sortable: false },
                        { label: '姓名', name: 'RealName', index: 'RealName', width: 100, align: "center", sortable: false },
                        { label: '职员', name: 'IsStaff', index: 'isStaff', width: 50, align: "center", formatter: "checkbox", sortable: false },
                        { label: '显示', name: 'IsVisible', index: 'IsVisible', width: 50, align: "center", formatter: "checkbox", sortable: false },
                        { label: '有效', name: 'Enabled', index: 'Enabled', width: 50, align: "center", formatter: "checkbox", sortable: false },
                        { label: '首次访问', name: 'FirstVisit', index: 'FirstVisit', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, datefmt: 'Y-m-d H:i:s', width: 170, align: "left", sortable: false },
                        { label: '下次访问', name: 'PreviousVisit', index: 'PreviousVisit', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, datefmt: 'Y-m-d H:i:s', width: 170, align: "left", sortable: false },
                        { label: '最后访问', name: 'LastVisit', index: 'LastVisit', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, datefmt: 'Y-m-d H:i:s', width: 170, align: "left", sortable: false },
                        { label: '登录次数', name: 'LogOnCount', index: 'LogOnCount', width: 80, align: "center", sortable: false },
                        { label: '在线', name: 'UserOnLine', index: 'UserOnLine', width: 50, align: "center", formatter: "checkbox", sortable: false },
                        { label: 'IP地址', name: 'IPAddress', index: 'IPAddress', width: 160, align: "center", sortable: false },
                        { label: 'Mac地址', name: 'MACAddress', index: 'MACAddress', width: 170, align: "center", sortable: false }
                       ],
            beforeRequest: function (d) {
                var checkFlag = $("#cbxShowOnLine").attr("checked") ? 1 : 0;
                $(this).jqGrid('setGridParam', { postData: { "check": checkFlag, "txtSearch": $("#txtkeyword_Permission_Log_Index").val()} });
            },
            loadError: function (xhr, status) {
                alertMsg.error(xhr.responseText);
            },
            loadComplete: function (xhr) {
                var ajaxbg = $("#background,#progressBar,#lui_List_Permission_Log_Index");
                ajaxbg.hide();
            },
            onSelectRow: User_GetLogList,
            autowidth: true,
            shrinkToFit: true,
            multiselect: false,
            sortable: false,
            viewrecords: true,
            sortorder: "desc",
            jsonReader: {
                repeatitems: false
            },
            rowNum: 20,
            altRows: true,
            pager: '#pager_Permission_Log_Index',
            rowList: [20, 50, 100],
            height: List_Permission_Log_Index_Height - 49
        }).navGrid('#pager_Permission_Log_Index', { edit: false, add: false, del: false, refresh: false, search: false });
    }
    //选中某一行，获得行
    function User_GetLogList() {
        var GridObj = $("#List_Permission_Log_Index");
        var logId_user = GridObj.jqGrid("getGridParam", "selrow");
        if (logId_user == "")
            return "";
        var temp_user = GridObj.getCell(parseInt(logId_user), "Id").toString();
        if (temp_user != "" && temp_user != "false") {
            $("#Details_Permission_Log_Index").attr("href", "/Permission/Log/QueryUser/" + temp_user);
        }
    }
    
    //实现模糊查询
    $().ready(function () {
        $("#txtkeyword_Permission_Log_Index").keyup(function () {
            reloadData_Permission_Log_Index();
        });
        //搜索按钮的点击事件处理
        //         $("#btnQuery_Permission_Log_Index").click(function () {
        //             reloadData_Permission_Log_Index();
        //         });
        //复选框点击事件处理
        $("#cbxShowOnLine").click(function () {
            reloadData_Permission_Log_Index();
        });
    });
    function reloadData_Permission_Log_Index() {
        $("#List_Permission_Log_Index").trigger("reloadGrid"); //重新加载JqGrid ;        
    }
</script>
<div class="page">
    @*顶部按钮*@
    <div class="panelBar">
        <ul class="toolBar">
            <li class="nobg">关键字：<input type="text" id="txtkeyword_Permission_Log_Index" />
            </li>
            <li>@Html.PermissionButton("Permission.Log.QueryUser", "Details_Permission_Log_Index", "input", "/Permission/Log/QueryUser/{sid_user}", "new_Details", "dialog", "详情", "true", "920", "480", "访问详情")</li>
            <li class="line">line</li>
            <li class="nobg">
                <input type="checkbox" id="cbxShowOnLine" />显示在线</li>
        </ul>
    </div>
    <div id="mainContent_Permission_Log_Index">
        <table id="List_Permission_Log_Index">
        </table>
        <div id="pager_Permission_Log_Index">
        </div>
    </div>
</div>
